import {observable,action} from 'mobx-miniprogram'
import ur from '../utils/extendApi'

export const base:any =  observable({
  token:ur.getStorageApi('token')||'',
  currentUserInfo:ur.getStorageApi('currentUserInfo')||{},

  setToken:action(function(token?:any){
    
    this.token=token
    if(!token){
      wx.redirectTo({
        url:'/pages/login/index'
      })
      ur.okToastApi({
        title:'退出成功'
      })
    }
  
  }),

  setCurrentUserInfo:action(function(currentUserInfo?:any){
    this.currentUserInfo=currentUserInfo
  })
})